﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace StudentManage
{
    public partial class Report : Form
    {
        public static bool flash;
        public Report()
        {
            InitializeComponent();
        }

        private void btntim_Click(object sender, EventArgs e)
        {
            if(texmssv.Text!="")
            {
                string sql = "select id,username from student where mssv='"+texmssv.Text+"'";
                DataTable student=XL_BANG.Doc(sql);
                XL_BANG.Xuat(student, comstudent);

                if (student.Rows.Count > 0)
                {
                    comstudent.Visible = true;
                    lblchonsv.Visible = true;

                }


            }
        }

        private void Report_Load(object sender, EventArgs e)
        {
            flash = true;
        }

        private void comstudent_MouseClick(object sender, MouseEventArgs e)
        {
            if (flash == true)
            {
                string sql = @"select s.lastname,s.firstname, s.username,g.total,g.courseid,su.name,c.examdate,t.name as term,y.name as year from student s,grade g, course c,subject su,term t,year y where t.yearid=y.id and t.id=c.termid and s.id=g.studentid and g.courseid= c.id and c.subjectid=su.id and s.id=" +
                    comstudent.SelectedValue.ToString() + "group by su.name,g.courseid,s.lastname,s.firstname, s.username,g.total,c.examdate,t.name,y.name";
                DataTable a = XL_BANG.Doc(sql);
                if (a.Rows.Count > 0)
                {
                    dtgReport.DataSource = a;
                    dtgReport.Visible = true;
                }
            }
        }

        private void Report_FormClosing(object sender, FormClosingEventArgs e)
        {
            MH_Import a = new MH_Import();
            a.Activate();
        }
    }
}
